using System;
using System.Collections.Generic;
using UnityEngine;

public class Events
{
	public enum EventDefinitionId
	{
		OneStarTournament = 0,
		TwoStarTournament = 1,
		ThreeStarTournament = 2
	}

	[Serializable]
	public class EventDefinition
	{
		public EventDefinitionId eventId;

		public List<EventStage> tournamentStages = new List<EventStage>();

		public int starCount
		{
			get
			{
				return (int)eventId;
			}
		}

		public EventStage GetStage(int index)
		{
			return tournamentStages[Mathf.Clamp(index, 0, tournamentStages.Count - 1)];
		}

		public virtual Type myObjectType()
		{
			return typeof(EventDefinition);
		}
	}

	[Serializable]
	public class Tournament : EventDefinition
	{
		public override Type myObjectType()
		{
			return typeof(Tournament);
		}
	}

	[Serializable]
	public class ExhibitionMatch : EventDefinition
	{
		public override Type myObjectType()
		{
			return typeof(ExhibitionMatch);
		}
	}

	[Serializable]
	public class PlayerId
	{
		public int playerDBIndex;

		public PlayerDB.TournamentPlayer player
		{
			get
			{
				return PlayerDB.instance.GetPlayer(playerDBIndex);
			}
		}

		public PlayerId Clone()
		{
			PlayerId playerId = new PlayerId();
			playerId.playerDBIndex = playerDBIndex;
			return playerId;
		}
	}

	[Serializable]
	public class EventStage
	{
		[Serializable]
		public class StageTier
		{
			public int MinWinsInclusive;

			public int MaxWinsInclusive;

			public int coinsForWin;

			public List<PlayerId> eligibleOpponents = new List<PlayerId>();
		}

		public string stageName;

		public List<StageTier> tiers = new List<StageTier>();

		public StageTier GetActiveTier(int wins)
		{
			foreach (StageTier tier in tiers)
			{
				if (wins <= tier.MaxWinsInclusive)
				{
					return tier;
				}
			}
			return tiers[tiers.Count - 1];
		}
	}
}
